<?php 
/* 
* Template Name: Profil
*/ 
	
	$serv="localhost";
    $user="admin";
    $pass="pw";
    $base="Pokerface";
    $db = @mysql_connect($serv, $user, $pass) or exit("Fehler bei Verbindung zur Datenbank: $serv $user<br/>");
    @mysql_select_db($base) or exit("Datenbank $base nicht vorhanden<br/>");
    $showsqlerrors=true;
    function sqlExit($sql)
    {
        global $showsqlerrors;
        if ($showsqlerrors)
            echo "Fehler in SQL-Kommando: $sql<br/>".mysql_error()."<br/>\n";
        exit();
    }
    function sqlQuery($sql)
    {
        $result=mysql_query($sql) or sqlExit($sql);
        return $result;
    }
	global $SMTheme;
	get_header();
	get_template_part('theloop');
	get_template_part('navigation');
	$mycurrent_user = wp_get_current_user();
	$myuserName = $mycurrent_user->user_login;
	$mysession = session_id();
	$sql = "UPDATE wp_users SET session='".$mysession."' WHERE user_login='".$myuserName."'";
	mysql_query($sql) or exit("Fehler im SQL-Kommando: $sql");
	
?>		
<?php
//Social Media Icons based on the profile user info
function member_social_extend(){
		$dmember_id = $bp->displayed_user->id;
		$fb_info = xprofile_get_field_data('facebook', $dmember_id);
		$google_info = xprofile_get_field_data('googleplus', $dmember_id);
		$twitch_info = xprofile_get_field_data('twitch', $dmember_id);
		$twitter_info = xprofile_get_field_data('twitter', $dmember_id);
		echo '<div class="member-social">';
		if($fb_info||$google_info||$twitch_info||$twitter_info){
			echo 'My Social: ';
		}

		if ($fb_info) {
		?>
		<span class="fb-info"><a href="https://www.facebook.com/<?php echo $fb_info; ?>"  title="My Facebook" target="_blank"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/karolina/images/social-profiles/facebook.png" /></a></span>
	<?php
	}
		?>
		<?php
		if ($google_info) {
		?>
		<span class="google-info"><a href="https://profiles.google.com/<?php echo $google_info; ?>" title="My Googleplus" target="_blank"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/your_theme_name_here/images/google-plus.png" /></a></span>
	<?php
	}
		?>
		<?php
		if ($twitch_info) {
		?>
		<span class="twitch-info"><a href="http://www.twitch.tv/<?php echo $twitch_info; ?>" title="My Twitch" target="_blank"><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/your_theme_name_here/images/twitch.png" /></a></span>
	<?php
	}
		?>
		<?php
		if ($twitter_info) {
		?>
		<span class="twitter-info"><a href="https://twitter.com/<?php echo $twitter_info; ?>" title="My Twitter" target="_blank" class="twitter-follow-button""><img src="<?php bloginfo('wpurl'); ?>/wp-content/themes/your_theme_name_here/images/twitter.png" /></a></span>
	<?php
	}
	echo '</div>';
}
add_filter( 'bp_before_member_header_meta', 'member_social_extend' ); ?>

<?php
	get_footer();
?>